<?php


use yii\helpers\Html;
use common\core\ActiveForm;
use common\helpers\ArrayHelper;
use yii\helpers\Url;
use kartik\date\DatePicker;

/* @var $this yii\web\View */
/* @var $model backend\models\JjrProject */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="jjr-project-form">

    <?php $form = ActiveForm::begin(['enableClientValidation'=>true,'validateOnBlur'=>true,'enableAjaxValidation'=>false]); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true])->hint(''); ?>
    <?= $form->field($model, 'price_name')->textInput() ?>
    <?= $form->field($model, 'price')->textInput() ?>



    <!-- 单图 -->
    <?=$form->field($model, 'main_pic')->widget('\common\widgets\images\Images',[
        //'type' => \backend\widgets\images\Images::TYPE_IMAGE, // 单图
        'saveDB'=>1, //图片是否保存到picture表，默认不保存
    ],['class'=>'c-md-12'])->label('楼盘图片')->hint('推荐图片尺寸为：800*600');?>

    <?=$form->field($model, 'real_pic')->widget('\common\widgets\images\Images',[
        'type' => \common\widgets\images\Images::TYPE_IMAGES, // 单图
        'saveDB'=>1, //图片是否保存到picture表，默认不保存
    ],['class'=>'c-md-12'])->label('实景图')->hint('推荐图片尺寸为：800*600');?>

    <?=$form->field($model, 'vr_pic')->widget('\common\widgets\images\Images',[
        'type' => \common\widgets\images\Images::TYPE_IMAGES, // 单图
        'saveDB'=>1, //图片是否保存到picture表，默认不保存
    ],['class'=>'c-md-12'])->label('效果图')->hint('推荐图片尺寸为：800*600');?>

    <?=$form->field($model, 'around_pic')->widget('\common\widgets\images\Images',[
        'type' => \common\widgets\images\Images::TYPE_IMAGES, // 单图
        'saveDB'=>1, //图片是否保存到picture表，默认不保存
    ],['class'=>'c-md-12'])->label('周边图')->hint('推荐图片尺寸为：800*600');?>

    <?= $form->field($model, 'commission_ad')->textInput(['maxlength' => true]) ?>






    <?= $form->field($model, 'commission_type')->radioList(['1'=>'固定金额','2'=>'百分比'],['class'=>'label-group']); ?>
    <?= $form->field($model, 'commission_fix')->textInput()->hint('当选择百分比方式不用填写');?>
    <?= $form->field($model, 'commission_percent')->textInput()->hint('当选择固定金额不用填写');?>





    <?= $form->field($model, 'adviser')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'adviser_mobile')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'tel')->textInput(['maxlength' => true]) ?>


    <div class="form-group">
        <div>
            <label>省 市 区</label>
            <span class="help-inline"></span>
        </div>
        <div class="col-md-2" style="padding-left:0px;">
            <?=\kartik\widgets\Select2::widget([
                'model' => $model,
                'attribute' => 'province',
                //'data' => '',
                'data' => ArrayHelper::map(\common\modelsgii\Region::find()->where(['parent_code'=>0])->asArray()->all(), 'code', 'fullname')
            ]);?>
        </div>


        <div class="col-md-2">
            <?=\kartik\widgets\DepDrop::widget([
                'model' => $model,
                'attribute' => 'city',
                'options' => ['placeholder' => '选择'],
                'type' => \kartik\widgets\DepDrop::TYPE_SELECT2,
                'select2Options'=>['pluginOptions'=>['allowClear'=>true]],
                'pluginOptions'=>[
                    //'initialize' => true,
                    //'initDepends'=>['order-province'],
                    'depends'=>['jjrproject-province'],
                    'url' => Url::to(['/public/region','sid'=>$model['city']]),
                    'loadingText' => '加载中',
                ]
            ]);?>
        </div>
        <div class="col-md-2">
            <?=\kartik\widgets\DepDrop::widget([
                'model' => $model,
                'attribute' => 'area',
                'options' => ['placeholder' => '选择'],
                'type' => \kartik\widgets\DepDrop::TYPE_SELECT2,
                'select2Options'=>['pluginOptions'=>['allowClear'=>true]],
                'pluginOptions'=>[
                    'initialize' => true,
                    'initDepends'=>['jjrproject-province'],
                    'depends'=>['jjrproject-city'],
                    'url' => Url::to(['/public/region','sid'=>$model['area']]),
                    'loadingText' => '加载中',
                ]
            ]);?>
        </div>
        <div style="clear:both;"></div>
    </div>
    <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
    <div class="form-group">
    <?php echo '<label class="control-label">选择转介时间</label>'; ?>
    <?= DatePicker::widget([
        'model' => $model,
        'attribute' => 'refer_start_time',
        'attribute2' => 'refer_end_time',
        'options' => ['placeholder' => '开始时间'],
        'options2' => ['placeholder' => '结束时间'],
        'type' => DatePicker::TYPE_RANGE,
        'form' => $form,
        'pluginOptions' => [
            'format' => 'yyyy-mm-dd',
            'autoclose' => true,
        ]
    ]); ?>
    </div>


    </div>


    <div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
